Release 10.1A: OpenEdge Development:
Programming Interfaces
Compiling procedures with aliases
As a general rule, you should not compile procedures while using aliases. This potentially leads to confusion about what database name ends up in the r-code. For example, the OpenEdge dictionary programs which contain
DICTDBas a qualifier must be compiled in a session where the database concerned has the logical nameDICTDB. That way, when the dictionary r-code is run, it can run for any database name as long as the database uses theDICTDBalias. In summary, logical names are useful for compiling, aliases are useful at runtime.However, you can still compile procedures using aliases. Suppose you have three databases called
eastdb,centraldb, andwestdb, all of which contain customer tables with identical structure and time stamps or CRC values. Your application requires a general report procedure that can run against any of these customer tables. To begin developing your general report procedure, start OpenEdge and connect to theeastdb,centraldb, orwestdbdatabase using the logical namemyalias. Develop and compile the customer report procedure usingmyaliasto prefix table and field references as shown in the previous procedurei-dispcust.p. All unqualified table and field references in the report procedurei-dispcust.presolve to themyaliaslogical name at compilation time. When you finish compiling your procedure, disconnect from the database represented by themyaliaslogical database name.You must assign an alias to the logical database name of a connected database prior to running any procedure that uses that alias as a database reference. Therefore, you need to develop a procedure that uses the
CREATEALIASstatement to assign themyaliasalias to a logical database name and run the report procedure (i-dispcust.p) as a subprocedure. See thei-alias2.pprocedure above.Although it is not recommended because of the possible confusion it can cause, you may need to compile a procedure with an alias. To do this, you must know how OpenEdge places database references in the r-code of the procedure at compilation time. Remember, you must assign the alias to a logical database name prior to compiling the procedure. In general, use only the alias as a database prefix for all table and field references in the general-purpose procedures, and always fully qualify every database reference within such a procedure. Use the following syntax:
If you use this syntax for every table or field reference in your procedure, only the alias will be represented as the database reference in the procedure’s r-code after compilation. Note that this is the only exception to the rule that you should never compile using aliases.
Unqualified table and field references within procedures may cause both the alias and the logical database name for a particular physical database to be represented in the r-code for the procedure at compilation time.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |